package com.jyw.business.de.domain.vo.web;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.business.de.domain.DeDemandResearch;
import com.jyw.common.annotation.Conversion;
import com.jyw.common.annotation.Excel;
import com.jyw.common.constant.SysDictTypeConstant;
import com.jyw.common.enums.ConversionType;
import com.jyw.common.utils.bean.BeanUtils;
import com.jyw.system.domain.vo.SimpleFileVo;
import com.jyw.system.utils.FileUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldNameConstants;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
@ApiModel("需求调研详情")
@FieldNameConstants
@NoArgsConstructor
public class DemandResearchVO {

    /** 主键 */
    @ApiModelProperty("主键")
    private Long id;

    /** 调研成员(集合) */
    @ApiModelProperty("调研成员(集合)")
    @Conversion(value = ConversionType.USER,name = Fields.researchUserName)
    private List<Long> researchUser;

    @ApiModelProperty("调研成员名称")
    private List<String> researchUserName;

    /** 涉及系统(数据字典多选) */
    @ApiModelProperty("涉及系统(数据字典多选)")
    @Conversion(value = ConversionType.DICT,dictType = SysDictTypeConstant.OBS_ABOUT_SYSTEM)
    private List<String> researchSystem;

    @ApiModelProperty("涉及系统名称")
    private List<String> researchSystemToName;

    /** 调研内容 */
    @ApiModelProperty("调研内容")
    private String researchRemark;

    /** 调研附件 */
    @ApiModelProperty("调研附件")
    private List<SimpleFileVo> researchEnclosure;

    /** 调研时间 */
    @ApiModelProperty("调研时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date researchTime;

    /** 创建人 */
    @ApiModelProperty("创建人")
    @Conversion(value = ConversionType.USER,name = Fields.createUserName)
    private Long createUser;

    /** 创建人 */
    @ApiModelProperty("创建人名称")
    private String createUserName;

    /** 创建时间 */
    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public DemandResearchVO(DeDemandResearch research) {
        BeanUtils.copyProperties(research,this);
        setResearchEnclosure(FileUtils.IdToFile(research.getResearchEnclosure()));
        setResearchSystem(Arrays.stream(research.getResearchSystem().split(",")).collect(Collectors.toList()));
        setResearchUser(Arrays.stream(research.getResearchUser().split(",")).map(data->Long.valueOf(data)).collect(Collectors.toList()));
    }
}
